<html>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<head>
	
<title>Coriander- 设置</title>
<style>
body {
  font-family:helvetica, arial, sans-serif;
  font-size:12px;
  margin:10px;
}
table {
  font-family:helvetica, arial, sans-serif;
   font-size:12px;
  margin:10px;
}
p {
  font-family:helvetica, arial, sans-serif;
  font-size:16px;
 
}
#header {
  padding-bottom:1.5em;
  padding-top:1.5em;
}

#header h1 {
  font-size: 156%;
  display:inline;
  padding-bottom:43px;
  padding-left:75px;
  padding-top:40px;
  background:url(img/coriander.png) no-repeat;
  background-size:67px;
  background-position:1px 18px;
}

.section-header {
  background:#ebeff9;
  border-top:1px solid #b5c7de;
  font-size:99%;
  padding:3px 0 2px 5px;
  font-weight:bold;
  margin-bottom:1em;
  margin-top:4em;
}

.section-header.first {
  margin-top:1em;
}

#custom-domain {
  width:300px;
  margin-left:2px;
}

#footer {
  margin-top:4em;
}
</style>
</head>
<script language=javascript> 
function verifyLogin()
{
 var xhr = new XMLHttpRequest(); 
  xhr.open("GET", "http://api.t.sina.com.cn/account/verify_credentials.json?source=3900123176", true); 
  xhr.onreadystatechange =  
  function() 
  { 
    if (xhr.readyState == 4) 
	 {
	   var myObject = JSON.parse(xhr.responseText); 
	   if(myObject.id==null)
	   {
	    document.getElementById("context").innerHTML="<p>请<a href='http://t.sina.com.cn' >登录</a>你的新浪微博,注意选择记住登录状态（第一次需要设置以后将自动登录）</p><a href='http://t.sina.com.cn' ><img src='img/options.png'></a>";
         localStorage.uid=0;
		}
	   else
	     localStorage.uid=myObject.id; //以登录微博获取用户ID
	 }
  };
  xhr.send(); 
  }

function init()
{
   if(localStorage.unfeed!=null)
   {
   document.all.notify.checked=(localStorage.notify=='true'?true:false);
   document.all.feed.checked=(localStorage.unfeed=='true'?true:false);
   document.all.follow.checked=localStorage.unfollow=='true'?true:false;
   document.all.fans.checked=localStorage.unfans=='true'?true:false;
   document.all.comment.checked=localStorage.uncomment=='true'?true:false;
   document.all.message.checked=localStorage.unmessage=='true'?true:false;
	for(var i=0;i<document.getElementsByName('fontsize').length;i++)
	if(document.getElementsByName('fontsize')[i].value==localStorage.fontSize)
	  document.getElementsByName('fontsize')[i].checked=true;
   for(var i=0;i<document.getElementsByName('fontFamily').length;i++)
	if(document.getElementsByName('fontFamily')[i].value==localStorage.fontFamily)
	  document.getElementsByName('fontFamily')[i].checked=true;
    for(var i=0;i<document.getElementsByName('theme').length;i++)
	if(document.getElementsByName('theme')[i].value==localStorage.theme)
	  document.getElementsByName('theme')[i].checked=true;
   for(var i=0;i<document.getElementsByName('allowSound').length;i++)
	if(document.getElementsByName('allowSound')[i].value==localStorage.allowSound)
	  document.getElementsByName('allowSound')[i].checked=true;
    document.all.loginedRefreshTime.value=localStorage.loginedRefreshTime;
   }
   verifyLogin();

}
function isInteger( str ){
var regu = /^[-]{0,1}[0-9]{1,}$/;
return regu.test(str);
}
function save()
{
  if(confirm('确定要保持设置么？'))
  { 
   localStorage.notify=document.all.notify.checked;
   localStorage.unfeed=document.all.feed.checked;
   localStorage.unfollow=document.all.follow.checked;
   localStorage.unfans=document.all.fans.checked;
   localStorage.uncomment=document.all.comment.checked;
   localStorage.unmessage=document.all.message.checked;
   for(var i=0;i<document.getElementsByName('theme').length;i++)
	if(document.getElementsByName('theme')[i].checked)
	  localStorage.theme=document.getElementsByName('theme')[i].value;
   for(var i=0;i<document.getElementsByName('allowSound').length;i++)
	if(document.getElementsByName('allowSound')[i].checked)
	  localStorage.allowSound=document.getElementsByName('allowSound')[i].value;
   for(var i=0;i<document.getElementsByName('fontsize').length;i++)
	if(document.getElementsByName('fontsize')[i].checked)
	  localStorage.fontSize=document.getElementsByName('fontsize')[i].value;
   for(var i=0;i<document.getElementsByName('fontFamily').length;i++)
	if(document.getElementsByName('fontFamily')[i].checked)
	  localStorage.fontFamily=document.getElementsByName('fontFamily')[i].value;
    if(isInteger(document.all.loginedRefreshTime.value)){
    localStorage.loginedRefreshTime=document.all.loginedRefreshTime.value;
    document.all.errSpan.innerHTML='';
	}
	else {document.all.errSpan.innerHTML='请输入正确的刷新频率！';return;}
   self.close();
  }
}

</script>
<body onload="init();">

<div id="header"><h1>Coriander - 新浪微博 chrome 插件配置</h1></div>
<div id="context"></div>
<div id="option">
<p>提醒设置：<font color=red>（该设置需要1次刷新后生效，见刷新频率设置）</font></p>
<table><tr><td>
<input name=feed  type=checkbox  >新微博数目
<input name=follow  type=checkbox   >新@我数目
<input name=fans  type=checkbox  >新粉丝数目
<input name=comment  type=checkbox  >新评论数目
<input name=message  type=checkbox  >新私信数目 
</td></tr></table>
<p>字体设置：<font color=red>（需要本机安装以下字体才会有效果） </font></p>
<table><tr><td><p>大小：</td><td>
<input name=fontsize  type=radio value='10px'  checked >小
<input name=fontsize  type=radio  value='14px' >中
<input name=fontsize type=radio  value='16px'>大
</td></tr>
<tr><td><p>风格：</td><td>
<input name=fontFamily  type=radio value='Arial,宋体'  checked >宋体
<input name=fontFamily  type=radio  value='Arial,微软雅黑' >微软雅黑
<input name=fontFamily type=radio  value='Arial,新宋体'>新宋体
</td></tr>
</table>
<p>主题设置：<input name=theme type=radio value='' checked>默认
<input name=theme type=radio value='-iphone' >节电模式</p>

<!--p>提示声音设置：</p>
<input name=allowSound type=radio value='true' checked>启用
<input name=allowSound type=radio value='false' >禁用-->
<p>刷新频率设置：<font color=red>（提醒数字的刷新频率）</font></p>
<table><tr><td>
<input name=loginedRefreshTime type=text size=10 maxLength=4>秒  <font color=red><span id=errSpan></span></font>
</td></tr></table>
<p>桌面通知设置：<input name=notify  type=checkbox  >是否启用</p>

<input type=button value='保存' onclick="save();" id=save>
</div>
<p>Chrome其他扩展推荐：</p>
<div><iframe src="http://ext4u.com/show/sida" frameborder="0" height="120" width="960"></iframe></div>  

</body>
</html>